import Axios from 'axios'

export default (url, data={}, type='GET') => {

  return new Promise((resolve, reject) => {
    let promise
    if(type === 'POST'){
      promise = Axios({
        url,
        data,
        method: 'POST'
      })
    }
    else {
      promise = Axios({
        url,
        params:data,
        method: 'GET'
      })
    }
    promise.then((response => {
      resolve(response.data)
    })).catch((err) => {
      reject(err)
    })
  })
}